package cn.silver.module.system.bean;

import cn.silver.framework.mybatis.bean.BusBean;
import cn.silver.framework.sensitive.annotation.Sensitive;
import cn.silver.framework.sensitive.core.SensitiveStrategy;
import cn.silver.framework.satoken.model.LoginUser;
import cn.silver.module.authority.bean.RoleBean;
import cn.silver.module.system.domain.SysUser;
import cn.silver.module.system.model.SysUserImportVo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.List;


/**
 * 用户信息视图对象 sys_user
 *
 * @author Silver Zhou
 */
@Data
@AutoMappers({
        @AutoMapper(target = SysUser.class),
        @AutoMapper(target = LoginUser.class, reverseConvertGenerate = false)
})
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Schema(name = "UserBean", title = "用户信息对象")
public class UserBean extends BusBean {
    /**
     * 用户类型（sys_user系统用户）
     */
    @Schema(title = "用户类型")
    private String type;

    /**
     * 用户邮箱
     */
    @Schema(title = "邮箱")
    @Sensitive(strategy = SensitiveStrategy.EMAIL)
    private String email;

    /**
     * 手机号码
     */
    @Schema(title = "手机号码")
    @Sensitive(strategy = SensitiveStrategy.PHONE)
    private String mobile;

    /**
     * 用户性别
     */
    @Schema(title = "性别")
    private String sex;

    /**
     * 用户头像
     */
    @Schema(title = "用户头像")
    private String avatar;

    /**
     * 密码
     */
    @JsonIgnore
    @JsonProperty
    @Schema(title = "密码")
    private String password;

    /**
     * 数据权限 当前角色ID
     */
    private String roleId;
    private String deptId;
    private String deptName;
    private List<String> postIds;
    private List<RoleBean> roles;
    private List<DeptBean> depts;

    public UserBean(String id, String code, String name, String type, String mobile, String status) {
        this.setId(id);
        this.setCode(code);
        this.setName(name);
        this.type = type;
        this.mobile = mobile;
        this.setStatus(status);
    }

    public void reload(SysUserImportVo userVo) {
    }
}
